package com.wo.cloud.tenant.config;

import com.wo.cloud.tenant.handler.WoCloudTenantHandler;
import com.wo.cloud.tenant.interceptor.FeignTenantInterceptor;
import com.wo.cloud.tenant.interceptor.TenantRequestInterceptor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.ClientHttpRequestInterceptor;

/**
 * @author liry
 * @version 1.0
 * @date Created on 2021/4/12 11:04
 * Description:
 */

@Configuration
public class TenantConfig {

    /**
     * 创建租户维护处理器对象
     *
     * @return 处理后的租户维护处理器
     */
    @Bean("woCloudTenantHandler")
    @ConditionalOnMissingBean
    public WoCloudTenantHandler woCloudTenantHandler() {
        return new WoCloudTenantHandler();
    }

    @Bean
    public ClientHttpRequestInterceptor clientHttpRequestInterceptor() {
        return new TenantRequestInterceptor();
    }

    @Bean
    public FeignTenantInterceptor feignTenantInterceptor(){
        return new FeignTenantInterceptor();
    }
}
